<?php

namespace App\Http\Requests\Admin\Service;

use Illuminate\Foundation\Http\FormRequest;

class ServiceCreate extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * 定义表单规则
     *
     * Date: 13/04/2018
     * @author Tenny
     * @return array
     */
    public function rules()
    {
        return [
            'designation' => 'required',
            'name' => 'required',
            'phone' => ['required', 'regex:/^(1[3456789])\d{9}$/', 'unique:service,phone'],
            'password' => 'required|min:6|max:18',
            'province_id' => 'required|integer',
            'city_id' => 'required|integer',
            'district_id' => 'required|integer',
            'address' => 'required|string',
            'scope' => 'required',
            'zoom' => 'required|integer',
            'bank_card' => 'required',
            'is_child' => 'required|integer',
            'pid' => 'nullable|integer',
        ];
    }

    /**
     * 定义错误响应消息
     *
     * Date: 13/04/2018
     * @author Tenny
     * @return array
     */
    public function messages()
    {
        return [
            'designation.required' => '请输入站点名称',
            'name.required' => '请输入负责人姓名',
            'phone.required' => '请输入店长手机号',
            'phone.regex' => '您输入正确的手机号码',
            'phone.unique' => '您输入的手机号码已存在',
            'password.required' => '请输入密码',
            'password.min' => '密码不得少于:min个字符',
            'password.max' => '密码不得超过:max个字符',
            'province_id.required' => '请选择省份',
            'province_id.integer' => '请选择正确的省份',
            'city_id.required' => '请选择市',
            'city_id.integer' => '请选择正确的市',
            'district_id.required' => '请选择区/县',
            'district_id.integer' => '请选择正确的区/县',
            'address.required' => '请输入地址',
            'address.string' => '请输入正确的地址',
            'scope.required' => '请选择经营范围',
            'zoom.required' => '请选择经营范围缩放级别',
            'zoom.integer' => '经营范围缩放级别不正确',
            'is_child.required' => '请选择站点类型',
            'is_child.integer' => '请选择正确的站点类型',
            'pid.integer' => '请选择正确的主站点',
        ];
    }
}
